<?php 
require_once('dao/OffreOptionDao.php');
if ($_SESSION['niveauAuth']=='1'or $_SESSION['niveauAuth']=='5'or $_SESSION['niveauAuth']=='8') {
//création d'une nouvelle offre mobile
if (isset($_POST['creation']))
{
$requete = $bdd->prepare("INSERT INTO `ha_option_mobile` (`id`, `code_article`, `nom`,`temps`, `sms`, `data`,`bb`,`international`) VALUES ('', '".$_POST['code_article']."', '".$_POST['nom']."', '".$_POST['temps']."','".$_POST['sms']."' ,'".$_POST['data']."','".$_POST['bb']."','".$_POST['international']."') ");
			
			$requete->execute() or exit(print_r($bdd->errorInfo()));


			
	//echo $_POST['action'];
	
	// Redirection vers la page 
	if ($_POST['action'] == "creation"){
			// Pas de changement de page
			$success=true;
	} else if ($_POST['action'] == "achat-option-mobile-creation"){
			header("Location:achat-option-mobile-creation?success=true");
	} else if ($_POST['action'] == "achat-option-mobile"){
		header("Location:achat-option-mobile.php?success=true");
	}
}

//$twig = new Twig_Environment($loader, array(
 //   'debug' => true,
//)); 
//$twig->addExtension(new Twig_Extension_Debug());
// a afficher dans le html: {{ debug() }}

echo $twig->render('achat-option-mobile-creation.html');

}
else {
	redirect("home-admin");
}
